package com.zx.map.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;

import com.zx.map.dao.model.ActiveRedpacket;
import com.zx.map.dao.model.Redpacket;

public interface RedpacketService {
	
	public int add(Redpacket redpacket) throws DataAccessException;
	
	public int update(Redpacket redpacket) throws DataAccessException;
	
	public void delete(int id) throws DataAccessException;

	public List<Redpacket> query(String merchantId) throws DataAccessException;
	/**
	 * 获取红包活动信息
	 * @param redpacketId
	 * @return
	 */
	public Redpacket info(int redpacketId) throws DataAccessException;
	/**
	 * 分页查询红包活动
	 * @param condition
	 * @return
	 */
	public List<Redpacket> queryByLimit(Map<String, Object> condition) throws DataAccessException;
	/**
	 * 判断该商户是否有已在进行的红包活动
	 * @param merchantId
	 * @return
	 */
	public boolean hasActiveRedpacket(String merchantId) throws DataAccessException;
	
	/**
	 * 查询该商户的有效红包活动
	 * @param merchantId
	 * @return
	 */
    public Redpacket queryRedpacketByMerchantId(String merchantId, BigDecimal totalMonbey) throws DataAccessException;
    /**
     * 增加红包的领取数量
     * @param redpacketId
     * @return
     */
    public int increaseJoinNum(Integer redpacketId) throws DataAccessException;
    /**
     * 红包被使用，修改红包活动的使用数量和修改刺激消费
     * @param id 红包领取表的id（active_redpacket）
     * @param consumeMoney
     * @return
     */
    public int dealRedpacketUsed(Map<String, Object> condition) throws DataAccessException;
    /**
     * 查询该活动的老会员的数量
     * @param redpacketId
     * @return
     */
    public int countOldVipNum(Integer redpacketId) throws DataAccessException;
    /**
     * 查询使用哪个红包
     * @return
     */
    public  ActiveRedpacket  selectUseRedpacket(String merchantId, String userId, BigDecimal consumeMoney) throws DataAccessException;
    /**
     * 检查开始时间或者结束时间是否小于当前时间
     * @param startDate
     * @param endDate
     * @return
     */
    public boolean checkStartAndEndDate(Date startDate, Date endDate) throws DataAccessException;
    /**
     * 获取红包信息，通知页面的数据
     * @param merchantId
     * @return
     */
    public Map<String, Object> noticeInfo(String merchantId, int pageNum, int pageSize) throws DataAccessException;
    /**
     * 获取用户红包金额
     * @param merchantId
     * @param useMoney
     * @return
     */
    public BigDecimal getMoney(String merchantId, BigDecimal useMoney) throws DataAccessException;
}
